import {
  getConfigList,
  postConfig,
  putConfig,
  deleteConfig
} from '@/api/config'
import {
  getToken,
  setToken,
  removeToken
} from '@/utils/auth'
import {
  resetRouter
} from '@/router'

const getDefaultState = () => {
}

const state = getDefaultState()

const mutations = {
}

const actions = {
  getConfigList({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      getConfigList(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  postConfig({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      postConfig(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putConfig({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putConfig(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  deleteConfig({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      deleteConfig(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
